package com.atguigu.product.controller;

import com.atguigu.product.Product;
import com.atguigu.product.service.ProductService;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RequestMapping("/api/oproduct")
@RestController
public class ProducrController {
    @Autowired
    private ProductService productService;
    //查询商品
    @RequestMapping("/productId/{id}")
    public Product getProduct(@PathVariable("id") Long productId , HttpServletRequest httpServletRequest) {
        HttpSession XToken = httpServletRequest.getSession();
        System.out.printf("Xtoken"+ XToken);
        System.out.printf("正在远远程调用service-product"+'\n');
        Product product = productService.getProductById(productId);
        return product;
    }
}
